package com.itheima.manager.web;

import com.itheima.manager.pojo.Contact;
import com.itheima.manager.service.ISelectByIdService;
import com.itheima.manager.service.imp.SelectByIdServiceImp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "SelectByIdServlet", value = "/SelectByIdServlet")
public class SelectByIdServlet extends HttpServlet {
    private ISelectByIdService iSelectByIdService = new SelectByIdServiceImp();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String id = request.getParameter("id");
        Contact contact = iSelectByIdService.selectAllById(Integer.parseInt(id));

        request.setAttribute("contact",contact);

        request.getRequestDispatcher("update.jsp").forward(request,response);

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          doGet(request,response);
    }
}
